package com.itcast.donkey.activity;

import android.graphics.Color;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;

import com.itcast.donkey.R;
import com.itcast.donkey.adapters.SeachAdapter;
import com.itcast.donkey.fragments.AbroadFragment;
import com.itcast.donkey.fragments.DomesticFragment;
import com.itcast.donkey.fragments.SeasonsFragment;
import com.itcast.donkey.utils.AssetsDatabaseManager;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by lanouhn on 16/8/26.
 */
public class SeachActivity extends AppCompatActivity {
    private ViewPager viewPager;
    private TabLayout tabs;
    private ImageView iv_chan_scenic_spot;
    private EditText et_seach;
    private RecyclerView recyclerView;
    private List<String> datas;
    private SeachAdapter adapter;
    private ArrayList<Fragment> lists = new ArrayList<Fragment>();
    String[] title = {"国外", "国内", "四季"};
    AbroadFragment abroadFragment;
    DomesticFragment domesticFragment;
    SeasonsFragment seasonsFragment;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_seach);


        initView();
        initData();
        initEnent();
    }

    private void initView() {
        et_seach = (EditText) findViewById(R.id.et_seach);
        viewPager = (ViewPager) findViewById(R.id.viewPager);
        tabs = (TabLayout) findViewById(R.id.tabs);
        iv_chan_scenic_spot = (ImageView) findViewById(R.id.iv_chan_scenic_spot);
    }

    private void initData() {
        abroadFragment = new AbroadFragment();
        domesticFragment = new DomesticFragment();
        seasonsFragment = new SeasonsFragment();
        lists.add(abroadFragment);
        lists.add(domesticFragment);
        lists.add(seasonsFragment);
        adapter = new SeachAdapter(getSupportFragmentManager(), lists, title);
        viewPager.setAdapter(adapter);
        tabs.setupWithViewPager(viewPager);
    }

    private void initEnent() {
        iv_chan_scenic_spot.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
//        et_seach.clearFocus();
//        et_seach.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                et_seach.requestFocus();
//            }
//        });
    }
}
